#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxm=1e6+10,maxn=2e5+10;;
ll arr[maxm];
ll temp[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        memset(arr,0,sizeof(arr));
        int n;
        cin>>n;
        ll Max=0;
        for(int i=1;i<=n;i++){
            cin>>temp[i];
            arr[temp[i]]++;
            Max=max(Max,temp[i]);
        }
        ll sum=0;
        for(int i=1;i<=Max;i++){
            sum+=(arr[i]/2)*i;
        }
        cout<<sum<<endl;
    }
    return 0;
}
